\chapter{Chapter 0: Installation and Basic Usage of Claude Code}

Claude Code is Anthropic's official CLI (Command Line Interface) that brings AI-powered development assistance directly to your terminal. This powerful tool can analyze codebases, write code, debug issues, and help with various development tasks. This chapter will guide you through the complete installation process and get you started with using Claude Code effectively.

\section{System Requirements}

Before installing Claude Code, ensure your system meets the following requirements:

\subsection{Operating System Support}
\begin{itemize}
\item \textbf{Linux}: Any modern distribution (Ubuntu, Debian, CentOS, Fedora, etc.)
\item \textbf{macOS}: macOS 10.14 or later
\item \textbf{Windows}: Windows 10/11 via WSL (Windows Subsystem for Linux)
\end{itemize}

\subsection{Hardware Requirements}
\begin{itemize}
\item \textbf{RAM}: Minimum 4GB, recommended 8GB or more
\item \textbf{Storage}: At least 2GB free space for installation and project files
\item \textbf{CPU}: Any modern x64 processor
\item \textbf{Network}: Stable internet connection for API calls and updates
\end{itemize}

\subsection{Software Dependencies}
\begin{itemize}
\item \textbf{Node.js}: Version 18.0 or higher (required for Claude Code runtime)
\item \textbf{npm}: Comes with Node.js installation
\item \textbf{Terminal}: Command-line interface (bash, zsh, PowerShell, etc.)
\end{itemize}

\section{Installation Guide}

\subsection{Windows Installation (via WSL)}

Windows users need to install WSL (Windows Subsystem for Linux) first, as Claude Code doesn't support Windows file systems directly.

\subsubsection{Understanding WSL}

WSL (Windows Subsystem for Linux) is Microsoft's compatibility layer that allows you to run a Linux environment directly on Windows without the overhead of a traditional virtual machine.

Think of WSL as having a "Linux workshop" inside your Windows computer. You can continue using Windows for daily tasks like browsing, gaming, and office work (your main living space), while WSL provides a professional development environment (your technical workshop) where tools like Claude Code run optimally.

Why use WSL for development?
\begin{itemize}
\item \textbf{Better Performance}: Linux-based tools run more efficiently in their native environment
\item \textbf{Compatibility}: Many development tools are designed primarily for Unix-like systems
\item \textbf{Isolation}: Keeps development environments separate from your main Windows system
\item \textbf{Flexibility}: Access to both Windows and Linux ecosystems
\end{itemize}

\textbf{System Requirements for WSL:}
\begin{itemize}
\item Windows 11 or Windows 10 version 21H2 or later
\item Professional, Enterprise, or Education edition (Home edition requires additional setup)
\item CPU with virtualization support enabled in BIOS/UEFI
\item At least 4GB RAM (8GB recommended)
\end{itemize}

\subsubsection{Step 1: Install WSL}

\begin{enumerate}
\item \textbf{Open Windows Terminal as Administrator}
\end{enumerate}
\begin{itemize}
\item Press \texttt{Win + R}, type \texttt{cmd}, then press \texttt{Ctrl + Shift + Enter}
\item Or search for "Command Prompt" in Start menu, right-click and select "Run as administrator"
\end{itemize}

\begin{enumerate}
\item \textbf{Install WSL with Ubuntu}
   ```bash
   wsl --install -d Ubuntu
   ```
\end{enumerate}

\begin{enumerate}
\item \textbf{Restart Your Computer}
   After installation completes, restart Windows to finalize the WSL setup.
\end{enumerate}

\begin{enumerate}
\item \textbf{Complete Ubuntu Setup}
\end{enumerate}
\begin{itemize}
\item Open the Ubuntu application from Start menu (it will appear after installation)
\item On first launch, you'll be prompted to create a Linux username and password
\item Choose a simple username (lowercase, no spaces) and remember your password
\end{itemize}

\textbf{Troubleshooting WSL Installation:}
\begin{itemize}
\item If you get an error, ensure virtualization is enabled in your BIOS/UEFI settings
\item For "WSL 2 requires an update to its kernel component" error, download and install the Linux kernel update package from Microsoft's website
\item If installation fails, try running \texttt{wsl --install --no-distribution} first, then \texttt{wsl --install -d Ubuntu}
\end{itemize}

\subsubsection{Step 2: Install Node.js in WSL}

\begin{enumerate}
\item \textbf{Open Ubuntu Terminal}
   You can access Ubuntu through:
\end{enumerate}
\begin{itemize}
\item Ubuntu app from Start menu
\item Windows Terminal (select Ubuntu from dropdown)
\item Command prompt by typing \texttt{wsl}
\end{itemize}

\begin{enumerate}
\item \textbf{Update Package Lists}
   ```bash
   sudo apt update \&\& sudo apt upgrade -y
   ```
\end{enumerate}

\begin{enumerate}
\item \textbf{Install Node.js 22.x}
   ```bash
   curl -fsSL https://deb.nodesource.com/setup\_22.x | sudo bash -
   sudo apt-get install -y nodejs
   ```
\end{enumerate}

\begin{enumerate}
\item \textbf{Verify Installation}
   ```bash
   node -v  \# Should show v22.x.x or higher
   npm -v   \# Should show npm version
   ```
\end{enumerate}

If the versions display correctly, Node.js is successfully installed and you can proceed to the next step.

\subsubsection{Step 3: Working with File Systems}

Understanding how to navigate between Windows and Linux file systems in WSL is crucial:

\textbf{Accessing Windows Files from WSL:}
\begin{itemize}
\item Windows drives are mounted under \texttt{/mnt/}
\item C: drive is accessible at \texttt{/mnt/c/}
\item D: drive is accessible at \texttt{/mnt/d/}
\end{itemize}

\begin{lstlisting}[language=bash]
# Navigate to your Windows Desktop
cd /mnt/c/Users/YourUsername/Desktop

# Navigate to a project folder on D: drive
cd /mnt/d/Projects/
\end{lstlisting}

\textbf{Accessing WSL Files from Windows:}
\begin{itemize}
\item Open Windows File Explorer
\item Navigate to \texttt{\\wsl.localhost\Ubuntu\}
\item Your Ubuntu home directory is at \texttt{\\wsl.localhost\Ubuntu\home\yourusername\}
\end{itemize}

\subsection{Linux/macOS Installation}

Direct installation on Linux and macOS is straightforward since these systems natively support the tools Claude Code requires.

\subsubsection{Step 1: Install Node.js}

\textbf{For Ubuntu/Debian:}
\begin{lstlisting}[language=bash]
# Update package lists
sudo apt update

# Install Node.js 22.x
curl -fsSL https://deb.nodesource.com/setup_22.x | sudo bash -
sudo apt-get install -y nodejs

# Verify installation
node -v && npm -v
\end{lstlisting}

\textbf{For CentOS/RHEL/Fedora:}
\begin{lstlisting}[language=bash]
# For CentOS/RHEL 8+
curl -fsSL https://rpm.nodesource.com/setup_22.x | sudo bash -
sudo dnf install -y nodejs npm

# For Fedora
sudo dnf install -y nodejs npm

# Verify installation
node -v && npm -v
\end{lstlisting}

\textbf{For macOS:}

Using Homebrew (recommended):
\begin{lstlisting}[language=bash]
# Install Homebrew if not already installed
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"

# Install Node.js
brew install node

# Verify installation
node -v && npm -v
\end{lstlisting}

Using official installer:
\begin{enumerate}
\item Download the LTS version from \href{https://nodejs.org/}{nodejs.org}
\item Run the installer package
\item Follow the installation wizard
\item Verify in terminal: \texttt{node -v && npm -v}
\end{enumerate}

\subsubsection{Step 2: System-Specific Preparations}

\textbf{For Linux:}
Ensure you have build tools installed for native modules:
\begin{lstlisting}[language=bash]
# Ubuntu/Debian
sudo apt install build-essential

# CentOS/RHEL/Fedora
sudo dnf groupinstall "Development Tools"
\end{lstlisting}

\textbf{For macOS:}
Install Xcode Command Line Tools:
\begin{lstlisting}[language=bash]
xcode-select --install
\end{lstlisting}

\subsection{Installing Claude Code}

Once Node.js is properly installed, you can install Claude Code. There are two main options: official Claude Code or alternative providers.

\subsubsection{Option 1: Official Claude Code}

\begin{lstlisting}[language=bash]
# Install official Claude Code globally
npm install -g @anthropic-ai/claude-code

# Verify installation
claude --version
\end{lstlisting}

\textbf{Note}: Official Claude Code requires:
\begin{itemize}
\item Valid Anthropic API key
\item Access to Claude API (may be restricted in some regions)
\item Credit card for API usage billing
\end{itemize}

\subsubsection{Option 2: Alternative Providers}

For users in regions with limited access or those seeking cost-effective alternatives, several proxy services are available.

\section{Backend Provider Configuration}

Claude Code supports multiple backend providers, each with different characteristics in terms of cost, capability, and accessibility.

\subsection{Available Backend Providers}

\subsubsection{1. GLM-4.5 (Most Cost-Effective)}
\begin{itemize}
\item \textbf{Provider}: BigModel (智谱AI)
\item \textbf{Pros}: Lowest cost, monthly subscription plans available
\item \textbf{Cons}: Limited compared to Claude's capabilities
\item \textbf{Best for}: Budget-conscious users, simple coding tasks
\end{itemize}

\subsubsection{2. GacCode (Claude Code Proxy)}
\begin{itemize}
\item \textbf{Provider}: GAC Mirror Service
\item \textbf{Pros}: Good balance of cost and capability, monthly plans, domestic accessibility
\item \textbf{Cons}: Third-party service, requires subscription
\item \textbf{Best for}: Users seeking Claude-like capabilities with better pricing
\end{itemize}

\subsubsection{3. DeepSeek-v3.1}
\begin{itemize}
\item \textbf{Provider}: DeepSeek AI
\item \textbf{Pros}: Strong coding capabilities, API-based pricing
\item \textbf{Cons}: More expensive than GLM/GacCode
\item \textbf{Best for}: Professional development work, complex coding tasks
\end{itemize}

\subsubsection{4. Kimi-k2}
\begin{itemize}
\item \textbf{Provider}: Moonshot AI
\item \textbf{Pros}: High capability, excellent reasoning
\item \textbf{Cons}: Most expensive option
\item \textbf{Best for}: Advanced AI assistance, research, complex problem-solving
\end{itemize}

\subsection{Cost and Capability Ranking}

\textbf{Cost Ranking (Cheapest to Most Expensive):}
\begin{enumerate}
\item GLM-4.5
\item GacCode
\item DeepSeek-v3.1
\item Kimi-k2
\end{enumerate}

\textbf{Capability Ranking (Basic to Advanced):}
\begin{enumerate}
\item GLM-4.5
\item DeepSeek-v3.1
\item Kimi-k2
\item GacCode (Claude-equivalent)
\end{enumerate}

\subsection{Provider Setup Instructions}

\subsubsection{GLM-4.5 Configuration}

\begin{enumerate}
\item \textbf{Sign Up for GLM Service}
\end{enumerate}
\begin{itemize}
\item Visit \href{https://open.bigmodel.cn}{open.bigmodel.cn}
\item Register for an account
\item Purchase a monthly plan or add credits
\item Obtain your API key from the dashboard
\end{itemize}

\begin{enumerate}
\item \textbf{Configure Environment Variables}
   ```bash
   \# Add to your \textasciitilde{}/.bashrc or \textasciitilde{}/.zshrc
   export ANTHROPIC\_BASE\_URL=https://open.bigmodel.cn/anthropic
   export ANTHROPIC\_API\_KEY=your\_glm\_api\_key\_here
   export ANTHROPIC\_MODEL=glm-4
\end{enumerate}
   
   \# Reload your shell configuration
   source \textasciitilde{}/.bashrc  \# or source \textasciitilde{}/.zshrc
   ```

\subsubsection{GacCode Configuration}

GacCode provides a Claude Code mirror with domestic accessibility.

\begin{enumerate}
\item \textbf{Sign Up for GacCode}
\end{enumerate}
\begin{itemize}
\item Visit \href{https://gaccode.com}{gaccode.com} (ensure you use .com domain)
\item Create an account using the referral link for bonus credits: \href{https://gaccode.com/signup?ref=OLWRETNE}{gaccode.com/signup?ref=OLWRETNE}
\end{itemize}

\begin{enumerate}
\item \textbf{Install GacCode Version}
   ```bash
   \# Remove official version if installed
   npm uninstall -g @anthropic-ai/claude-code
\end{enumerate}
   
   \# Install GacCode version
   sudo npm install -g https://gaccode.com/claudecode/install --registry=https://registry.npmmirror.com
   
   \# Verify installation
   claude --version
   ```

\begin{enumerate}
\item \textbf{Subscription and Activation}
\end{enumerate}
\begin{itemize}
\item Purchase a subscription plan on the GacCode website
\item Alternatively, use trial codes (check \href{https://chatshare.uno}{chatshare.uno} for current codes)
\item On first run, Claude Code will open a browser for account verification
\end{itemize}

\subsubsection{DeepSeek Configuration}

\begin{enumerate}
\item \textbf{Get DeepSeek API Key}
\end{enumerate}
\begin{itemize}
\item Register at \href{https://platform.deepseek.com}{platform.deepseek.com}
\item Add credits to your account
\item Generate an API key in the API Keys section
\end{itemize}

\begin{enumerate}
\item \textbf{Set Environment Variables}
   ```bash
   \# Add to your shell configuration
   export ANTHROPIC\_BASE\_URL=https://api.deepseek.com/anthropic
   export ANTHROPIC\_AUTH\_TOKEN=your\_deepseek\_api\_key
   export ANTHROPIC\_MODEL=deepseek-reasoner
   export ANTHROPIC\_SMALL\_FAST\_MODEL=deepseek-chat
\end{enumerate}
   
   \# Create a wrapper script (optional)
   cat > \textasciitilde{}/bin/dclaude << 'EOF'
   \#!/bin/bash
   export ANTHROPIC\_BASE\_URL=https://api.deepseek.com/anthropic
   export ANTHROPIC\_AUTH\_TOKEN=\$\{DEEPSEEK\_API\_KEY\}
   export ANTHROPIC\_MODEL=deepseek-reasoner
   export ANTHROPIC\_SMALL\_FAST\_MODEL=deepseek-chat
   claude --dangerously-skip-permissions "\$@"
   EOF
   chmod +x \textasciitilde{}/bin/dclaude
   ```

\subsubsection{Kimi Configuration}

\begin{enumerate}
\item \textbf{Obtain Kimi API Access}
\end{enumerate}
\begin{itemize}
\item Sign up at \href{https://platform.moonshot.cn}{platform.moonshot.cn}
\item Purchase credits or subscribe to a plan
\item Generate API key in your dashboard
\end{itemize}

\begin{enumerate}
\item \textbf{Configure Environment}
   ```bash
   \# Set environment variables
   export ANTHROPIC\_BASE\_URL=https://api.moonshot.cn/anthropic/
   export ANTHROPIC\_API\_KEY=your\_kimi\_api\_key
   export ANTHROPIC\_MODEL=kimi-k2-0905-preview
\end{enumerate}
   
   \# Create wrapper script
   cat > \textasciitilde{}/bin/kclaude << 'EOF'
   \#!/bin/bash
   export ANTHROPIC\_BASE\_URL=https://api.moonshot.cn/anthropic/
   export ANTHROPIC\_API\_KEY=\$KIMI\_API\_KEY
   export ANTHROPIC\_MODEL=kimi-k2-0905-preview
   claude --dangerously-skip-permissions "\$@"
   EOF
   chmod +x \textasciitilde{}/bin/kclaude
   ```

\subsection{Environment Variable Management}

For better organization and security, create a configuration file to manage your API keys:

\begin{lstlisting}[language=bash]
# Create config directory
mkdir -p ~/.config/claude-code

# Create environment file
cat > ~/.config/claude-code/.env << 'EOF'
# Claude Code Backend Configuration

# GLM-4.5 Configuration
GLM\_API\_KEY=your\_glm\_api\_key\_here
GLM\_BASE\_URL=https://open.bigmodel.cn/anthropic

# DeepSeek Configuration
DEEPSEEK\_API\_KEY=your\_deepseek\_api\_key\_here
DEEPSEEK\_BASE\_URL=https://api.deepseek.com/anthropic

# Kimi Configuration
KIMI\_API\_KEY=your\_kimi\_api\_key\_here
KIMI\_BASE\_URL=https://api.moonshot.cn/anthropic/

# Default Backend (change as needed)
ANTHROPIC\_BASE\_URL=${DEEPSEEK\_BASE\_URL}
ANTHROPIC\_AUTH\_TOKEN=${DEEPSEEK\_API\_KEY}
ANTHROPIC\_MODEL=deepseek-reasoner
EOF

# Secure the file
chmod 600 ~/.config/claude-code/.env

# Source in your shell profile
echo 'source ~/.config/claude-code/.env' >> ~/.bashrc
\end{lstlisting}

\subsection{API Key Security Best Practices}

\begin{enumerate}
\item \textbf{Never commit API keys to version control}
   ```bash
   \# Add to .gitignore
   echo "*.env" >> \textasciitilde{}/.gitignore
   echo ".claude-config" >> \textasciitilde{}/.gitignore
   ```
\end{enumerate}

\begin{enumerate}
\item \textbf{Use environment variables instead of hardcoding}
\item \textbf{Regularly rotate API keys}
\item \textbf{Monitor API usage and costs}
\item \textbf{Use separate keys for different projects if possible}
\end{enumerate}

\section{Installation Verification}

After completing your chosen installation method, verify everything is working correctly:

\subsection{Basic Verification}

\begin{enumerate}
\item \textbf{Check Claude Code Installation}
   ```bash
   claude --version
   ```
\end{enumerate}

\begin{enumerate}
\item \textbf{Test Basic Functionality}
   ```bash
   \# Create a test directory
   mkdir \textasciitilde{}/claude-test
   cd \textasciitilde{}/claude-test
\end{enumerate}
   
   \# Start Claude Code
   claude
   ```

\begin{enumerate}
\item \textbf{Verify Backend Connection}
   In the Claude Code interface, try a simple query:
   ```
   Hello! Please confirm you can access the backend API and tell me which model you're using.
   ```
\end{enumerate}

\subsection{Common Installation Issues}

\subsubsection{"command not found: claude"}
\begin{lstlisting}[language=bash]
# Check if npm global bin is in PATH
npm config get prefix

# If not in PATH, add to your shell profile
echo 'export PATH="$(npm config get prefix)/bin:$PATH"' >> ~/.bashrc
source ~/.bashrc
\end{lstlisting}

\subsubsection{"No such file or directory" on Windows WSL}
Ensure you're running Claude Code from within the WSL environment, not Windows Command Prompt.

\subsubsection{"Permission denied" errors}
\begin{lstlisting}[language=bash]
# Fix npm permissions
mkdir ~/.npm-global
npm config set prefix '~/.npm-global'
echo 'export PATH=~/.npm-global/bin:$PATH' >> ~/.bashrc
source ~/.bashrc

# Reinstall Claude Code
npm install -g @anthropic-ai/claude-code
\end{lstlisting}

\subsubsection{API connection failures}
\begin{enumerate}
\item Verify your API keys are correct
\item Check your internet connection
\item Ensure the base URL is properly formatted
\item Try switching to a different backend provider
\end{enumerate}

\subsection{Performance Optimization}

\subsubsection{For WSL Users}
\begin{lstlisting}[language=bash]
# Add Windows file system access optimization
echo '# Optimize Windows file access' >> ~/.bashrc
echo 'export WSLENV=PATH/l:HOME/l' >> ~/.bashrc

# Configure WSL memory usage (create /etc/wsl.conf)
sudo tee /etc/wsl.conf > /dev/null << EOF
[wsl2]
memory=4GB
processors=2
localhostForwarding=true
EOF
\end{lstlisting}

\subsubsection{For All Users}
\begin{lstlisting}[language=bash]
# Increase Node.js memory limit for large projects
echo 'export NODE\_OPTIONS="--max-old-space-size=4096"' >> ~/.bashrc
source ~/.bashrc
\end{lstlisting}

\section{Getting Started with Your First Session}

Now that Claude Code is installed and configured, let's start your first session:

\subsection{Creating a Project Directory}

\begin{lstlisting}[language=bash]
# Create and navigate to a project directory
mkdir ~/my-first-claude-project
cd ~/my-first-claude-project

# Initialize a simple project structure
echo "# My First Claude Code Project" > README.md
mkdir src
echo 'console.log("Hello, Claude Code!");' > src/app.js
\end{lstlisting}

\subsection{Starting Claude Code}

\begin{lstlisting}[language=bash]
# Start Claude Code in your project directory
claude
\end{lstlisting}

On the first run, Claude Code will:
\begin{enumerate}
\item Analyze your project structure
\item Ask for permission to access files in the current directory
\item Potentially open a browser window for authentication (depending on your backend)
\item Present you with the Claude Code interface
\end{enumerate}

\subsection{Initial Configuration Tips}

When Claude Code starts for the first time:

\begin{enumerate}
\item \textbf{Grant File Access}: Allow Claude Code to read and write files in your project directory
\item \textbf{Choose Working Mode}: Select whether you want Claude to have broad or limited file access
\item \textbf{Set Preferences}: Configure your preferred editor integration and display options
\end{enumerate}

For WSL users, add this memory instruction to help Claude understand your environment:
\begin{lstlisting}
Remember: You're running in WSL. When saving files, use /mnt/ paths to access the Windows file system if needed.
\end{lstlisting}

This completes the installation and basic setup of Claude Code. You now have a fully functional Claude Code installation with your chosen backend provider configured. The next sections will cover basic usage patterns, common commands, and how to effectively interact with Claude Code for various development tasks.

\section{Quick Reference Card}

\subsection{Essential Commands}
\begin{lstlisting}[language=bash]
# Start Claude Code in current directory
claude

# Check version
claude --version

# Start with specific permissions
claude --dangerously-skip-permissions

# Exit Claude Code
Type 'exit' or press Ctrl+C
\end{lstlisting}

\subsection{Environment Variables Quick Reference}
\begin{lstlisting}[language=bash]
# Backend Configuration
ANTHROPIC\_BASE\_URL=https://api.your-provider.com
ANTHROPIC\_API\_KEY=your\_api\_key
ANTHROPIC\_MODEL=your\_model\_name

# Common Models
# - deepseek-reasoner (DeepSeek)
# - kimi-k2-0905-preview (Kimi)
# - glm-4 (GLM)
\end{lstlisting}

\subsection{File System Access (WSL)}
\begin{lstlisting}[language=bash]
# Windows files from WSL
/mnt/c/Users/YourName/

# WSL files from Windows
\\wsl.localhost\Ubuntu\home\yourusername\
\end{lstlisting}

This foundational setup prepares you for the practical usage scenarios covered in the following sections of this chapter.

\chapter{Basic Usage}

Now that Claude Code is installed and configured, let's explore how to effectively use it for development tasks. This section covers the essential commands, workflows, and features that will help you become productive with Claude Code quickly.

\section{Command Line Interface Basics}

Claude Code provides a rich set of command-line options that control its behavior and capabilities. Understanding these options is crucial for effective usage.

\subsection{Essential Command-Line Options}

Based on the official CLI reference, here are the most important flags and options:

\subsubsection{Core Commands}
\begin{lstlisting}[language=bash]
# Start Claude Code in the current directory
claude

# Start with specific permissions
claude --dangerously-skip-permissions

# Check version and help
claude --version
claude --help

# Add additional working directories
claude --add-dir ../apps ../lib

# Start with custom tool permissions
claude --allowedTools "Bash(git log:\textit{)" "Bash(git diff:})" "Write"
claude --disallowedTools "Bash(rm:\textit{)" "Bash(sudo:})"
\end{lstlisting}

\subsubsection{Directory Management}
\begin{lstlisting}[language=bash]
# Add multiple working directories
claude --add-dir /path/to/project1 /path/to/project2

# Start in a specific directory context
cd /your/project/directory && claude
\end{lstlisting}

\subsection{Starting Your First Claude Code Session}

When you run \textbackslash\{\}texttt\{claude\} in a project directory, several things happen:

\begin{enumerate}
\item \textbf{Directory Analysis}: Claude Code scans your project structure to understand the codebase
\item \textbf{Permission Requests}: You'll be prompted to grant file access permissions
\item \textbf{Context Loading}: Available files, git status, and project configuration are loaded
\item \textbf{Interface Initialization}: The interactive Claude Code interface starts
\end{enumerate}

\textbf{Example first session:}
\begin{lstlisting}[language=bash]
# Navigate to your project
cd ~/my-project

# Start Claude Code
claude

# You'll see output like:
# Claude Code v1.2.3
# Scanning project directory...
# Found 45 files across 8 directories
# Git repository detected (main branch, 3 uncommitted changes)
\chapter{}
# Would you like to grant Claude access to read and write files in this directory? (y/n)
\end{lstlisting}

\subsection{Basic Conversation Patterns}

Once Claude Code starts, you interact with it through natural language. Here are effective conversation patterns:

\subsubsection{Code Analysis Requests}
\begin{lstlisting}
"Can you analyze the structure of this project and explain what it does?"

"Review the main.py file and suggest improvements"

"Find all TODO comments in the codebase"
\end{lstlisting}

\subsubsection{Development Tasks}
\begin{lstlisting}
"Help me implement a user authentication system using Flask"

"Debug this error I'm getting: [paste error message]"

"Refactor the calculate\_total function to be more efficient"
\end{lstlisting}

\subsubsection{File Operations}
\begin{lstlisting}
"Create a new Python file called utils.py with helper functions"

"Update the README.md with installation instructions"

"Show me the git diff for the last commit"
\end{lstlisting}

\section{Core Features and Commands}

\subsection{File Operations and Code Analysis}

Claude Code excels at understanding and manipulating codebases. Here are the key capabilities:

\subsubsection{Reading and Understanding Code}
Claude Code can automatically read files in your project and understand relationships between them:

\begin{lstlisting}
User: "What does this application do?"
Claude: I'll analyze your project structure to understand what this application does.

[Claude reads multiple files and provides comprehensive analysis]
\end{lstlisting}

\subsubsection{Code Generation and Modification}
\begin{lstlisting}
User: "Add error handling to the database connection function"
Claude: I'll add proper error handling to your database connection. Let me first examine the current implementation...

[Claude reads the relevant files, then suggests and implements improvements]
\end{lstlisting}

\subsubsection{Project Structure Analysis}
\begin{lstlisting}
User: "Can you create a diagram showing how the different modules interact?"
Claude: I'll analyze your project structure and create a visual representation of module interactions...
\end{lstlisting}

\subsection{Getting Help and Documentation}

Claude Code has several ways to provide assistance:

\subsubsection{Built-in Help Commands}
\begin{lstlisting}[language=bash]
# Within Claude Code session
/help              # Show available commands
/mcp              # List installed MCP servers
/agents           # Show available sub-agents
\end{lstlisting}

\subsubsection{Asking for Explanations}
\begin{lstlisting}
"Explain how this authentication system works"
"What are the dependencies of this project?"
"How do I run the tests for this codebase?"
\end{lstlisting}

\subsection{Session Management and Context}

Claude Code maintains context throughout your session, remembering:
\begin{itemize}
\item Files you've discussed
\item Code changes made
\item Project structure understanding
\item Previous conversations
\end{itemize}

\subsubsection{Managing Long Sessions}
\begin{lstlisting}
"Can you summarize what we've accomplished in this session?"
"Let's start working on a new feature - forget the previous debugging context"
"Save our progress and create a summary for the next session"
\end{lstlisting}

\subsubsection{Context Boundaries}
Claude Code operates within the directory where it was started. To work with files outside this directory, you need to:
\begin{itemize}
\item Use \texttt{--add-dir} flag when starting
\item Grant explicit permissions for new directories
\item Start a new session in the target directory
\end{itemize}

\subsection{Simple Development Workflows}

\subsubsection{Basic Debugging Workflow}
\begin{enumerate}
\item \textbf{Describe the Problem}
   ```
   "I'm getting a 500 error when users try to login. Can you help debug this?"
   ```
\end{enumerate}

\begin{enumerate}
\item \textbf{Let Claude Analyze}
   Claude will examine relevant files, logs, and configuration
\end{enumerate}

\begin{enumerate}
\item \textbf{Review Suggestions}
   Claude will provide specific fixes and explanations
\end{enumerate}

\begin{enumerate}
\item \textbf{Implement Changes}
   Claude can make the changes directly or guide you through them
\end{enumerate}

\begin{enumerate}
\item \textbf{Test and Verify}
   ```
   "Can you help me test this fix?"
   ```
\end{enumerate}

\subsubsection{Code Review Workflow}
\begin{enumerate}
\item \textbf{Request Review}
   ```
   "Please review the changes I made to user.py"
   ```
\end{enumerate}

\begin{enumerate}
\item \textbf{Get Feedback}
   Claude analyzes code quality, security, and best practices
\end{enumerate}

\begin{enumerate}
\item \textbf{Apply Improvements}
   Claude suggests and can implement improvements
\end{enumerate}

\begin{enumerate}
\item \textbf{Documentation Update}
   ```
   "Update the docstrings to reflect these changes"
   ```
\end{enumerate}

\section{Sub-Agent Usage}

Sub-agents are one of Claude Code's most powerful features, allowing you to break complex tasks into specialized, focused components that work in parallel.

\subsection{What are Sub-Agents?}

Sub-agents are specialized instances of Claude that focus on specific tasks within your project. Think of them as having different team members with specific expertise:

\begin{itemize}
\item \textbf{Main Agent}: Project manager who coordinates overall work
\item \textbf{Sub-Agents}: Specialists who handle specific tasks (testing, documentation, frontend, backend, etc.)
\end{itemize}

\subsection{When to Use Sub-Agents}

Sub-agents are beneficial for:
\begin{itemize}
\item \textbf{Complex Multi-Step Projects}: Breaking down large features into manageable pieces
\item \textbf{Parallel Development}: Working on multiple unrelated features simultaneously
\item \textbf{Specialized Tasks}: Having dedicated agents for testing, documentation, code review
\item \textbf{Avoiding Context Pollution}: Keeping task-specific context separate from main conversation
\end{itemize}

\subsection{Creating and Managing Sub-Agents}

\subsubsection{Using the Built-in Command}
\begin{lstlisting}[language=bash]
# Within Claude Code session
/agents
\end{lstlisting}

This command shows available sub-agents and allows you to create new ones.

\subsubsection{Manual Sub-Agent Creation}

\textbf{Project-Level Sub-Agents} (highest priority):
\begin{lstlisting}[language=bash]
# Create the agents directory
mkdir -p .claude/agents

# Create a specialized sub-agent
cat > .claude/agents/testing-specialist.md << 'EOF'
# Testing Specialist Sub-Agent

You are a testing specialist focused on:
\begin{itemize}
\item Writing comprehensive unit tests
\item Creating integration tests
\item Setting up test automation
\item Code coverage analysis
\item Performance testing
\end{itemize}

\section{Guidelines}
\begin{itemize}
\item Always prioritize test coverage and quality
\item Follow TDD (Test-Driven Development) principles
\item Use appropriate testing frameworks for the language
\item Focus on edge cases and error conditions
\item Maintain test documentation
\end{itemize}

\section{Constraints}
\begin{itemize}
\item Only work on testing-related tasks
\item Do not modify production code unless fixing test-breaking changes
\item Always run tests before completing tasks
\end{itemize}
EOF
\end{lstlisting}

\textbf{User-Level Sub-Agents} (cross-project availability):
\begin{lstlisting}[language=bash]
# Create user-level agents directory
mkdir -p ~/.claude/agents

# Create a documentation specialist
cat > ~/.claude/agents/documentation-specialist.md << 'EOF'
# Documentation Specialist Sub-Agent

You specialize in creating and maintaining project documentation:
\begin{itemize}
\item API documentation
\item User guides and tutorials
\item Code comments and docstrings
\item README files and project overviews
\item Architecture documentation
\end{itemize}

\section{Guidelines}
\begin{itemize}
\item Write clear, concise, and comprehensive documentation
\item Follow documentation best practices for the project's language/framework
\item Keep documentation up-to-date with code changes
\item Include examples and use cases
\item Consider the target audience (developers, users, administrators)
\end{itemize}
EOF
\end{lstlisting}

\subsection{Sub-Agent Coordination Basics}

Sub-agents work within an isolated context, receiving only the information needed for their specific task. Here's how coordination works:

\subsubsection{Task Assignment Pattern}
\begin{lstlisting}
Main Session: "I need to implement a user authentication system"

Sub-Agent Creation: Create authentication specialist
Sub-Agent Task: "Implement OAuth2 authentication with JWT tokens"

Main Session: Meanwhile, work on UI components
Sub-Agent Completion: Receives authentication implementation
Integration: Main agent integrates sub-agent work into main project
\end{lstlisting}

\subsubsection{Communication Flow}
\begin{enumerate}
\item \textbf{Main Agent} analyzes the overall task
\item \textbf{Task Decomposition} breaks work into specialized chunks
\item \textbf{Sub-Agent Creation} creates focused agents for each chunk
\item \textbf{Parallel Execution} sub-agents work independently
\item \textbf{Result Integration} main agent combines all work
\item \textbf{Quality Review} ensures consistency across all changes
\end{enumerate}

\subsection{Simple Sub-Agent Examples}

\subsubsection{Example 1: Feature Development with Testing}
\begin{lstlisting}
Main Task: "Add user profile management feature"

# Create sub-agents
/agents
Create: frontend-developer.md - Focus on UI/UX for profile management
Create: backend-developer.md - Focus on API endpoints and data models  
Create: testing-specialist.md - Focus on comprehensive testing

# Assign tasks
Frontend Sub-Agent: "Create profile management UI components"
Backend Sub-Agent: "Implement profile CRUD API endpoints"
Testing Sub-Agent: "Write tests for profile management feature"
\end{lstlisting}

\subsubsection{Example 2: Code Quality Improvement}
\begin{lstlisting}
Main Task: "Improve code quality across the project"

# Specialized sub-agents
Create: code-reviewer.md - Focus on code analysis and improvements
Create: documentation-updater.md - Focus on keeping docs current
Create: performance-optimizer.md - Focus on performance improvements

# Parallel execution
Code Reviewer: "Analyze and refactor authentication.py"
Documentation: "Update API documentation for recent changes"  
Performance: "Optimize database queries in user module"
\end{lstlisting}

\subsubsection{Example 3: Bug Investigation}
\begin{lstlisting}
Main Task: "Investigate and fix performance issues"

# Investigation team
Create: bug-investigator.md - Focus on finding root causes
Create: performance-analyzer.md - Focus on performance metrics
Create: fix-implementer.md - Focus on implementing solutions

# Coordinated debugging
Investigator: "Analyze error logs and identify performance bottlenecks"
Analyzer: "Profile the application and measure current performance"
Implementer: "Apply fixes based on investigation findings"
\end{lstlisting}

\section{MCP (Model Context Protocol) Integration}

Model Context Protocol (MCP) is a standardized way to extend Claude Code's capabilities by connecting it to external tools, services, and data sources.

\subsection{What is MCP and Its Benefits}

MCP provides several key advantages:

\begin{itemize}
\item \textbf{Standardized Integration}: Uniform way to add new capabilities to Claude Code
\item \textbf{Extended Functionality}: Access to databases, APIs, file systems, and external services
\item \textbf{Modular Design}: Add only the tools you need for your specific workflow
\item \textbf{Cross-Project Reusability}: MCP servers can be shared across different projects
\item \textbf{Real-time Data Access}: Connect to live data sources and services
\end{itemize}

\subsection{Basic MCP Server Installation and Management}

\subsubsection{Installing MCP Servers}

Claude Code provides a simple command to install MCP servers:

\begin{lstlisting}[language=bash]
# Basic installation (project-level)
claude mcp add <server-name>

# User-level installation (available across all projects)
claude mcp add <server-name> --scope user

# Examples
claude mcp add filesystem
claude mcp add github
claude mcp add database
claude mcp add weather
\end{lstlisting}

\subsubsection{Common MCP Server Examples}

\textbf{Filesystem Server} - Enhanced file operations:
\begin{lstlisting}[language=bash]
claude mcp add filesystem
# Provides: Advanced file search, batch operations, file monitoring
\end{lstlisting}

\textbf{GitHub Integration}:
\begin{lstlisting}[language=bash]
claude mcp add github
# Provides: Repository management, issue tracking, PR creation
# Requires: GITHUB\_TOKEN environment variable
\end{lstlisting}

\textbf{Database Connectivity}:
\begin{lstlisting}[language=bash]
claude mcp add database  
# Provides: SQL query execution, schema analysis, data visualization
# Requires: Database connection strings
\end{lstlisting}

\textbf{Web Search and APIs}:
\begin{lstlisting}[language=bash]
claude mcp add web-search
# Provides: Real-time web search, API data retrieval
\end{lstlisting}

\subsection{Project-Level vs User-Level MCP Installation}

\subsubsection{Project-Level Installation (Default)}
\begin{lstlisting}[language=bash]
# Install for current project only
claude mcp add memory

# Configuration stored in: .claude/mcp\_servers.json
# Benefits: Project-specific tools, team collaboration, version control
\end{lstlisting}

\subsubsection{User-Level Installation}
\begin{lstlisting}[language=bash]
# Install for all projects
claude mcp add memory --scope user

# Configuration stored in: ~/.claude/mcp\_servers.json
# Benefits: Personal workflow tools, consistent across projects
\end{lstlisting}

\subsection{Viewing Installed MCPs}

Within a Claude Code session:
\begin{lstlisting}[language=bash]
# List all available MCP servers
/mcp

# Example output:
# Available MCP Servers:
# ✓ filesystem (project-level) - File system operations
# ✓ github (user-level) - GitHub integration
# ✓ memory (project-level) - Persistent memory across sessions
# ✓ web-search (user-level) - Web search capabilities
\chapter{}
# 4 servers active, 12 tools available
\end{lstlisting}

\subsection{Basic MCP Configuration Examples}

\subsubsection{Manual MCP Configuration}

For advanced users, you can manually configure MCP servers by editing the configuration files:

\textbf{Project-level configuration} (\texttt{.claude/mcp\_servers.json}):
\begin{lstlisting}[language=bash]
{
  "mcpServers": {
    "filesystem": {
      "command": "npx",
      "args": ["-y", "@modelcontextprotocol/server-filesystem", "/path/to/allowed/files"]
    },
    "memory": {
      "command": "npx", 
      "args": ["-y", "@modelcontextprotocol/server-memory"]
    },
    "custom-api": {
      "command": "python",
      "args": ["/path/to/your/custom-mcp-server.py"],
      "env": {
        "API\_KEY": "${YOUR\_API\_KEY}",
        "BASE\_URL": "https://api.example.com"




\end{lstlisting}

\textbf{User-level configuration} (\texttt{~/.claude/mcp\_servers.json}):
\begin{lstlisting}[language=bash]
{
  "mcpServers": {
    "github": {
      "command": "npx",
      "args": ["-y", "@modelcontextprotocol/server-github"],
      "env": {
        "GITHUB\_PERSONAL\_ACCESS\_TOKEN": "${GITHUB\_TOKEN}"

    },
    "weather": {
      "command": "python", 
      "args": ["-m", "weather\_mcp\_server"],
      "env": {
        "WEATHER\_API\_KEY": "${WEATHER\_API\_KEY}"




\end{lstlisting}

\subsubsection{Environment Variable Setup}

Create a \textbackslash\{\}texttt\{.env\} file for MCP server credentials:
\begin{lstlisting}[language=bash]
# Create environment file for MCP credentials
cat > ~/.claude/.env << 'EOF'
GITHUB\_TOKEN=your\_github\_personal\_access\_token
WEATHER\_API\_KEY=your\_weather\_api\_key  
DATABASE\_URL=postgresql://user:pass@localhost/db
API\_KEY=your\_custom\_api\_key
EOF

# Secure the file
chmod 600 ~/.claude/.env

# Source in your shell profile
echo 'export $(cat ~/.claude/.env | grep -v "^#" | xargs)' >> ~/.bashrc
\end{lstlisting}

\section{Essential Workflows}

\subsection{Starting Your First Development Session}

Here's a step-by-step guide to your first productive Claude Code session:

\subsubsection{Step 1: Project Preparation}
\begin{lstlisting}[language=bash]
# Navigate to your project
cd ~/projects/my-web-app

# Ensure git is initialized
git status || git init

# Start Claude Code
claude
\end{lstlisting}

\subsubsection{Step 2: Project Discovery}
\begin{lstlisting}
"Hi Claude! This is my first time using Claude Code. Can you help me understand what this project is about and how I can work with it effectively?"
\end{lstlisting}

Claude will:
\begin{itemize}
\item Analyze your project structure
\item Identify the technology stack
\item Understand the project's purpose
\item Suggest immediate next steps
\end{itemize}

\subsubsection{Step 3: Define Your Goals}
\begin{lstlisting}
"I want to add user authentication to this web application. Can you help me plan this feature?"
\end{lstlisting}

\subsubsection{Step 4: Implement with Guidance}
\begin{lstlisting}
"Let's start implementing the authentication system. Please guide me through the process step by step."
\end{lstlisting}

\subsection{Basic Code Debugging Workflow}

\subsubsection{1. Problem Description}
\begin{lstlisting}
"I'm getting this error when users try to register: 
[Error] TypeError: Cannot read property 'email' of undefined
at validateUser (auth.js:45)"
\end{lstlisting}

\subsubsection{2. Context Gathering}
Claude will automatically:
\begin{itemize}
\item Examine the error location (auth.js:45)
\item Review related files
\item Check for similar patterns in the codebase
\end{itemize}

\subsubsection{3. Root Cause Analysis}
\begin{lstlisting}
Claude: "I've found the issue. In your \texttt{validateUser} function, you're trying to access the \texttt{email} property before checking if the user object exists. Let me show you the fix..."
\end{lstlisting}

\subsubsection{4. Solution Implementation}
\begin{lstlisting}
"Please implement the fix and also add proper error handling for similar cases."
\end{lstlisting}

\subsubsection{5. Testing and Verification}
\begin{lstlisting}
"Can you help me write a test case to prevent this bug from happening again?"
\end{lstlisting}

\subsection{Simple Project Development Patterns}

\subsubsection{Pattern 1: Feature-Driven Development}
\begin{lstlisting}[language=bash]
# Start with feature planning
"I want to add a blog system to my website. Help me break this down into manageable tasks."

# Create sub-agents for different aspects
/agents
# Create: blog-backend.md, blog-frontend.md, blog-testing.md

# Implement in phases
"Let's start with the backend data models and API endpoints"
"Now let's create the frontend components"  
"Finally, let's add comprehensive testing"
\end{lstlisting}

\subsubsection{Pattern 2: Refactoring and Improvement}
\begin{lstlisting}[language=bash]
# Code quality assessment
"Analyze my current codebase and identify areas that need refactoring"

# Prioritized improvements
"Let's start with the most critical issues first"

# Incremental changes
"Refactor one module at a time, ensuring tests pass after each change"
\end{lstlisting}

\subsubsection{Pattern 3: Bug Investigation and Resolution}
\begin{lstlisting}[language=bash]
# Issue reproduction
"Help me reproduce this bug that users are reporting"

# Systematic debugging
"Let's add logging and debugging statements to track down the issue"

# Fix implementation
"Implement a fix and add regression tests"
\end{lstlisting}

\subsection{Getting Help When Stuck}

\subsubsection{Understanding Error Messages}
\begin{lstlisting}
"I don't understand this error message: [paste error]. Can you explain what it means and how to fix it?"
\end{lstlisting}

\subsubsection{Learning New Technologies}
\begin{lstlisting}
"I'm new to React. Can you explain the component structure in this project and help me understand how to add a new component?"
\end{lstlisting}

\subsubsection{Best Practices Guidance}
\begin{lstlisting}
"Am I following best practices in this code? What improvements would you suggest?"
\end{lstlisting}

\subsubsection{Performance Optimization}
\begin{lstlisting}
"My application is running slowly. Can you help me identify performance bottlenecks and optimize the code?"
\end{lstlisting}

\section{Best Practices for Beginners}

\subsection{How to Structure Effective Prompts}

\subsubsection{Be Specific and Clear}
\begin{lstlisting}
\\textcolor{red}{$\\times$} Bad: "Fix my code"
\\textcolor{green}{$\\checkmark$} Good: "The login function in auth.js is returning a 500 error when users enter invalid credentials. Can you help me add proper error handling?"
\end{lstlisting}

\subsubsection{Provide Context}
\begin{lstlisting}
\\textcolor{red}{$\\times$} Bad: "Add a feature"
\\textcolor{green}{$\\checkmark$} Good: "I'm building an e-commerce site using Node.js and Express. I need to add a shopping cart feature that stores items in localStorage and syncs with the backend when users log in."
\end{lstlisting}

\subsubsection{Break Down Complex Tasks}
\begin{lstlisting}
\\textcolor{red}{$\\times$} Bad: "Build a complete user management system"
\\textcolor{green}{$\\checkmark$} Good: "Let's build a user management system step by step:
\begin{enumerate}
\item First, help me create the user data model
\item Then we'll add registration and login endpoints  
\item Finally, we'll create the frontend forms"
\end{enumerate}
\end{lstlisting}

\subsubsection{Ask for Explanations}
\begin{lstlisting}
"Can you explain why you chose this approach?"
"What are the trade-offs of this solution?"
"How does this code work?"
\end{lstlisting}

\subsection{Managing Conversation Context}

\subsubsection{Start Fresh When Needed}
\begin{lstlisting}
"Let's start working on a new feature. Please forget our previous discussion about debugging and focus on implementing the payment system."
\end{lstlisting}

\subsubsection{Summarize Progress}
\begin{lstlisting}
"Can you summarize what we've accomplished in this session and what our next steps should be?"
\end{lstlisting}

\subsubsection{Reference Previous Work}
\begin{lstlisting}
"Earlier in this session, you helped me implement user authentication. Now I want to use that authentication system for the admin panel."
\end{lstlisting}

\subsubsection{Save Important Decisions}
\begin{lstlisting}
"Please create a summary of the architecture decisions we've made and save them to DECISIONS.md"
\end{lstlisting}

\subsection{When to Start New Sessions}

\subsubsection{Context Overload}
Start a new session when:
\begin{itemize}
\item The conversation has covered many different topics
\item You're switching to a completely different project area
\item The context has become confusing or contradictory
\end{itemize}

\subsubsection{Major Direction Changes}
\begin{lstlisting}
# End current session, start new one
"We've been debugging authentication, but now I need to focus entirely on the database design. Let me start a new session for this."
\end{lstlisting}

\subsubsection{Daily Work Boundaries}
\begin{itemize}
\item Start fresh each day with a new session
\item Begin new sessions for major features or refactoring tasks
\item Use new sessions when collaborating with different team members
\end{itemize}

\subsection{Common Beginner Mistakes to Avoid}

\subsubsection{1. Not Granting Appropriate Permissions}
\begin{lstlisting}
\\textcolor{red}{$\\times$} Mistake: Denying file access permissions
\\textcolor{green}{$\\checkmark$} Solution: Grant necessary permissions for Claude to help effectively
\end{lstlisting}

\subsubsection{2. Being Too Vague}
\begin{lstlisting}
\\textcolor{red}{$\\times$} Mistake: "My code doesn't work"
\\textcolor{green}{$\\checkmark$} Solution: "The user registration form on line 45 of register.js is not validating email addresses properly"
\end{lstlisting}

\subsubsection{3. Not Providing Error Messages}
\begin{lstlisting}
\\textcolor{red}{$\\times$} Mistake: "There's an error"
\\textcolor{green}{$\\checkmark$} Solution: "I'm getting this specific error: [paste complete error message with stack trace]"
\end{lstlisting}

\subsubsection{4. Overwhelming Claude with Too Much Context}
\begin{lstlisting}
\\textcolor{red}{$\\times$} Mistake: Pasting entire large files
\\textcolor{green}{$\\checkmark$} Solution: Focus on specific functions or sections relevant to your question
\end{lstlisting}

\subsubsection{5. Not Testing Suggestions}
\begin{lstlisting}
\\textcolor{red}{$\\times$} Mistake: Implementing multiple changes without testing
\\textcolor{green}{$\\checkmark$} Solution: Test each change incrementally and report results back to Claude
\end{lstlisting}

\subsubsection{6. Ignoring Best Practices}
\begin{lstlisting}
\\textcolor{red}{$\\times$} Mistake: Asking for quick hacks
\\textcolor{green}{$\\checkmark$} Solution: Ask for proper, maintainable solutions with explanations
\end{lstlisting}

\section{Quick Reference}

\subsection{Essential Commands Cheat Sheet}

\subsubsection{Starting and Configuration}
\begin{lstlisting}[language=bash]
claude                              # Start Claude Code
claude --version                    # Check version
claude --help                       # Show help
claude --add-dir ../lib ../apps     # Add additional directories
claude --dangerously-skip-permissions # Skip permission prompts
\end{lstlisting}

\subsubsection{Within Claude Code Session}
\begin{lstlisting}[language=bash]
/help                   # Show available commands
/mcp                    # List MCP servers  
/agents                 # Manage sub-agents
/exit                   # Exit Claude Code
\end{lstlisting}

\subsubsection{MCP Management}
\begin{lstlisting}[language=bash]
claude mcp add <name>              # Install MCP server (project-level)
claude mcp add <name> --scope user # Install MCP server (user-level)
claude mcp list                    # List available MCP servers
claude mcp remove <name>           # Remove MCP server
\end{lstlisting}

\subsection{Common Usage Patterns}

\subsubsection{Code Analysis}
\begin{lstlisting}
"Analyze this project structure"
"Review the code in [filename]"
"Find security issues in this authentication code"
"Suggest improvements for this function"
\end{lstlisting}

\subsubsection{Development Tasks}
\begin{lstlisting}
"Implement [specific feature] using [technology]"
"Add error handling to [function name]"
"Refactor this code to be more maintainable"
"Create tests for this module"
\end{lstlisting}

\subsubsection{Debugging}
\begin{lstlisting}
"Help me debug this error: [error message]"
"Why is this function not working as expected?"
"Find the root cause of this performance issue"
"Add logging to help diagnose this problem"
\end{lstlisting}

\subsubsection{Project Management}
\begin{lstlisting}
"Create a roadmap for implementing [feature]"
"Break down this large task into smaller steps"
"Help me prioritize these technical debt items"
"Plan the architecture for this new system"
\end{lstlisting}

\subsection{Troubleshooting Guide for Beginners}

\subsubsection{Claude Code Won't Start}
\begin{lstlisting}[language=bash]
# Check installation
claude --version

# Check Node.js
node --version  # Should be 18+ 

# Reinstall if needed
npm install -g @anthropic-ai/claude-code

# Check permissions
ls -la $(which claude)
\end{lstlisting}

\subsubsection{Permission Errors}
\begin{lstlisting}[language=bash]
# Fix npm permissions
mkdir ~/.npm-global
npm config set prefix '~/.npm-global'
echo 'export PATH=~/.npm-global/bin:$PATH' >> ~/.bashrc
source ~/.bashrc
\end{lstlisting}

\subsubsection{API Connection Issues}
\begin{lstlisting}[language=bash]
# Check environment variables
echo $ANTHROPIC\_API\_KEY
echo $ANTHROPIC\_BASE\_URL

# Test network connectivity
curl -I https://api.anthropic.com

# Try alternative backend
export ANTHROPIC\_BASE\_URL=https://api.deepseek.com/anthropic
\end{lstlisting}

\subsubsection{File Access Problems}
\begin{lstlisting}
# Within Claude Code, grant broader permissions:
"I'm getting file access errors. Can you help me configure the proper permissions?"

# Or restart with skip permissions flag:
claude --dangerously-skip-permissions
\end{lstlisting}

\subsubsection{MCP Server Issues}
\begin{lstlisting}[language=bash]
# Check MCP configuration
cat .claude/mcp\_servers.json

# Verify server installation
which npx  # For npm-based servers
pip list | grep mcp  # For Python-based servers

# Test individual server
npx @modelcontextprotocol/server-filesystem --help
\end{lstlisting}

\subsubsection{Performance Issues}
\begin{lstlisting}[language=bash]
# Increase Node.js memory
export NODE\_OPTIONS="--max-old-space-size=4096"

# For WSL users - configure memory limits
sudo nano /etc/wsl.conf
# Add: [wsl2]
# memory=4GB
\end{lstlisting}

\subsection{Getting More Help}

\subsubsection{Within Claude Code}
\begin{lstlisting}
"I'm new to Claude Code. Can you give me a tour of what you can help me with?"
"What are the most useful features for [your specific use case]?"
"Show me examples of how to [specific task]"
\end{lstlisting}

\subsubsection{Community Resources}
\begin{itemize}
\item Official Documentation: \href{https://docs.anthropic.com/claude-code}{docs.anthropic.com/claude-code}
\item GitHub Issues: Report bugs and feature requests
\item Community Forums: Discuss best practices and workflows
\item MCP Server Registry: Discover available MCP servers
\end{itemize}

\subsubsection{Learning Resources}
\begin{lstlisting}
"Can you recommend resources for learning [specific technology]?"
"What are the best practices for [specific development task]?"
"Show me examples of well-structured [type of project]?"
\end{lstlisting}

This comprehensive guide should give you a solid foundation for using Claude Code effectively. Remember that Claude Code is designed to be conversational and helpful - don't hesitate to ask questions, request explanations, and experiment with different approaches to find what works best for your development workflow.